package com.cloud.drore.eboss.sso.dao;

import com.cloud.drore.eboss.sso.entity.EbossRoleRightRelation;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

@Transactional
@Repository
public interface RoleRightRelationDao extends BaseDao<EbossRoleRightRelation, Long> {

    void deleteByRoleId(Long rightId);

    @Query(value = "select r.id,r.create_by,r.modified_by,r.created_date,r.modified_date,r.tenant_id,right_id,role_id,f.right_code from  shiro_role_right_relation r,shiro_function f where r.right_id = f.id and r.role_id = :roleId",nativeQuery=true)
    List<EbossRoleRightRelation> findByRoleId(@Param("roleId") Long roleId);
}